#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

using namespace cv;
using namespace std;

int main()
{
    vector<Mat> channels;
    vector<vector<Point>> contours;
    vector<Vec4i> hierachy;
    Mat srcImage = imread("orange.jpg");
    Mat gaussImage;
    Mat bluechannel;
    Mat binImage;
  
    GaussianBlur(srcImage, gaussImage, Size(3, 3), 0);
    split(gaussImage, channels);
    bluechannel = channels.at(0);
    threshold(bluechannel, binImage, 25, 255, THRESH_BINARY_INV);
    findContours(binImage, contours, hierachy, RETR_EXTERNAL, CHAIN_APPROX_NONE);
    drawContours(srcImage, contours, 20, Scalar(255, 0, 0), 2, 8);

	imshow("CONTOURS", srcImage);

    waitKey(0);
    return 0;
}